forum

home / developersection / forums / convert date in string to datetime with same format

Convert date in string to DateTime with same format

Anonymous User 2016 10-May-2013
Hi Guys!

I have a string that has a date stored in it.

String date = "03-05-2013 00:00:00";
I parsed it to Datetime as follows:

DateTime Start = DateTime.Parse(date);
Start.ToString() gave me "3/5/2013 12:0:00 AM"

I also used:

DateTime Start = DateTime.ParseExact(date,"dd-MM-yyyy HH:mm:ss",CultureInfo.InvariantCulture);
Then, Start.ToString() gave me "3/5/2013 12:0:00 AM", which is the exact same result as the previous one. I need to keep the original formatting. How may I do it? 

Thanks in in advance!. 

c# c# 
Updated on 10-May-2013

I am a content writter !


Message
Can you answer this question?

Answer

1 Answers

Liked By